/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('tianchi', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AilabSaasUpdateTenantRequest {
  description?: string(name='Description'),
  name?: string(name='Name'),
  tenantId?: long(name='TenantId'),
}

model AilabSaasUpdateTenantResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
}

model AilabSaasUpdateTenantResponse = {
  headers: map[string]string(name='headers'),
  body: AilabSaasUpdateTenantResponseBody(name='body'),
}

async function ailabSaasUpdateTenantWithOptions(request: AilabSaasUpdateTenantRequest, runtime: Util.RuntimeOptions): AilabSaasUpdateTenantResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.name)) {
    body['Name'] = request.name;
  }
  if (!Util.isUnset(request.tenantId)) {
    body['TenantId'] = request.tenantId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AilabSaasUpdateTenant',
    version = '2021-06-04',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function ailabSaasUpdateTenant(request: AilabSaasUpdateTenantRequest): AilabSaasUpdateTenantResponse {
  var runtime = new Util.RuntimeOptions{};
  return ailabSaasUpdateTenantWithOptions(request, runtime);
}

